﻿namespace HRM.CORE
{
    using DevExpress.XtraEditors;
    using Microsoft.VisualBasic;
    using Common.Class; using APP.HELPER.Utils.Language; using Security.Security; using Dictionary.ERP;
    using System; using Extra.ERP;
    using System.Collections;
    using System.ComponentModel;
    using System.Data;
    using System.Data.SqlClient;
    using System.Threading;
    using System.Windows.Forms; using Common;
    using APP.HELPER.Utils.CustomizeToolbox;
    using APP.HELPER.Data.Helper;
    using Dictionary.ERP;
    using APP.HELPER.Utils;

    public class HRM_TIMEKEEPER
    {
        private System.DateTime m_Date;
        private double m_DayHour;
        private string m_Description;
        private int m_EarlyMinute;
        private string m_EmployeeCode;
        private double m_Hour;
        private bool m_IsOverTime;
        private bool m_IsWork;
        private int m_LateMinute;
        private double m_NightHour;
        private double m_PrivateHour;
        private string m_ShiftCode;
        private int m_Sorted;
        private string m_Symbol;
        private System.DateTime m_TimeIn;
        private Guid m_TimeKeeperTableListID;
        private System.DateTime m_TimeOut;

        public HRM_TIMEKEEPER()
        {
            this.m_TimeKeeperTableListID = Guid.Empty;
            this.m_EmployeeCode = "";
            this.m_ShiftCode = "";
            this.m_Date = System.DateTime.Now;
            this.m_Symbol = "";
            this.m_Hour = 0.0;
            this.m_DayHour = 0.0;
            this.m_NightHour = 0.0;
            this.m_PrivateHour = 0.0;
            this.m_LateMinute = 0;
            this.m_EarlyMinute = 0;
            this.m_IsOverTime = false;
            this.m_IsWork = false;
            this.m_Sorted = 0;
            this.m_Description = "";
        }

        public HRM_TIMEKEEPER(Guid TimeKeeperTableListID, string EmployeeCode, string ShiftCode, System.DateTime Date, string Symbol, double Hour, double DayHour, double NightHour, double PrivateHour, int LateMinute, int EarlyMinute, bool IsOverTime, bool IsWork, int Sorted, string Description)
        {
            this.m_TimeKeeperTableListID = TimeKeeperTableListID;
            this.m_EmployeeCode = EmployeeCode;
            this.m_ShiftCode = ShiftCode;
            this.m_Date = Date;
            this.m_Symbol = Symbol;
            this.m_Hour = Hour;
            this.m_DayHour = DayHour;
            this.m_NightHour = NightHour;
            this.m_PrivateHour = PrivateHour;
            this.m_LateMinute = LateMinute;
            this.m_EarlyMinute = EarlyMinute;
            this.m_IsOverTime = IsOverTime;
            this.m_IsWork = IsWork;
            this.m_Sorted = Sorted;
            this.m_Description = Description;
        }

        public void AddCombo(System.Windows.Forms.ComboBox combo)
        {
            GridCalendarControlLib.TableToComboBox(combo, this.GetList(), "TimeKeeperTableListName", "TimeKeeperID");
        }

        public void AddComboAll(System.Windows.Forms.ComboBox combo)
        {
            DataTable list = new DataTable();
            list = this.GetList();
            DataRow row = list.NewRow();
            row["TimeKeeperTableListID"] = "All";
            row["TimeKeeperTableListName"] = "Tất cả";
            list.Rows.InsertAt(row, 0);
            GridCalendarControlLib.TableToComboBox(combo, list, "TimeKeeperTableListName", "TimeKeeperTableListID");
        }

        public void AddComboEdit(ComboBoxEdit combo)
        {
            DataTable list = new DataTable();
            list = this.GetList();
            foreach (DataRow row in list.Rows)
            {
                combo.Properties.Items.Add(row["TimeKeeperTableListName"]);
            }
        }

        public void AddGridLookupEdit(GridLookUpEdit gridlookup)
        {
            DataTable list = new DataTable();
            list = this.GetList();
            gridlookup.Properties.DataSource = list;
            gridlookup.Properties.DisplayMember = "TimeKeeperTableListName";
            gridlookup.Properties.ValueMember = "TimeKeeperTableListID";
        }

        public string Create(Guid TimeKeeperTableListID, DataTable Employeess)
        {
            HRM_TIMEKEEPER_TOTAL l_TimeKeeperTotal = new HRM_TIMEKEEPER_TOTAL();
            IEnumerator enumerator = Employeess.Rows.GetEnumerator();
            {
                ThreadStart start = null;
                ThreadStart start2 = null;
                DataRow dr;
                while (enumerator.MoveNext())
                {
                    dr = (DataRow) enumerator.Current;
                    Options.SetWaitDialogCaption("Đang khởi tạo..." + dr["FirstName"].ToString() + " " + dr["LastName"].ToString() + " (" + dr["EmployeeCode"].ToString() + ")");
                    if (start == null)
                    {
                        start = delegate {
                            this.Create(TimeKeeperTableListID, dr["EmployeeCode"].ToString());
                        };
                    }
                    Thread thread = new Thread(start);
                    thread.Start();
                    thread.Join();
                    if (start2 == null)
                    {
                        start2 = delegate {
                            l_TimeKeeperTotal.Create(TimeKeeperTableListID, dr["EmployeeCode"].ToString());
                        };
                    }
                    Thread thread2 = new Thread(start2);
                    thread2.Start();
                    thread2.Join();
                }
            }
            Options.HideDialog();
            return "OK";
        }

        public string Create(Guid TimeKeeperTableListID, string EmployeeCode)
        {
            string[] myParams = new string[] { "@TimeKeeperTableListID", "@EmployeeCode" };
            object[] myValues = new object[] { TimeKeeperTableListID, EmployeeCode };
            SqlHelper helper = new SqlHelper();
            return helper.ExecuteNonQuery("HRM_TIMEKEEPER_Create", myParams, myValues);
        }

        public string Create(int Level, string Code, Guid TimeKeeperTableListID)
        {
            HRM_TIMEKEEPER_TABLELIST hrm_timekeeper_tablelist = new HRM_TIMEKEEPER_TABLELIST();
            hrm_timekeeper_tablelist.GetByID(TimeKeeperTableListID);
            int year = hrm_timekeeper_tablelist.Year;
            int month = hrm_timekeeper_tablelist.Month;
            System.DateTime dayFirstMonth = new System.DateTime(year, month, 1);
            System.DateTime dayEndMonth = new System.DateTime(year, month, System.DateTime.DaysInMonth(year, month));
            HRM_EMPLOYEE hrm_employee = new HRM_EMPLOYEE();
            HRM_TIMEKEEPER_TOTAL l_TimeKeeperTotal = new HRM_TIMEKEEPER_TOTAL();
            IEnumerator enumerator = hrm_employee.GetCompactList(Level, Code, 1, dayFirstMonth, dayEndMonth).Rows.GetEnumerator();
            {
                ThreadStart start = null;
                ThreadStart start2 = null;
                DataRow dr;
                while (enumerator.MoveNext())
                {
                    dr = (DataRow) enumerator.Current;
                    HRM_TIMEKEEPER hrm_timekeeper = new HRM_TIMEKEEPER();
                    if (hrm_timekeeper.GetListByEmployee(dr["EmployeeCode"].ToString(), month, year).Rows.Count <= 0)
                    {
                        Options.SetWaitDialogCaption("Đang cập nhật..." + dr["FirstName"].ToString() + " " + dr["LastName"].ToString() + " (" + dr["EmployeeCode"].ToString() + ")");
                        if (start == null)
                        {
                            start = delegate {
                                this.Create(TimeKeeperTableListID, dr["EmployeeCode"].ToString());
                            };
                        }
                        Thread thread = new Thread(start);
                        thread.Start();
                        thread.Join();
                        if (start2 == null)
                        {
                            start2 = delegate {
                                l_TimeKeeperTotal.Create(TimeKeeperTableListID, dr["EmployeeCode"].ToString());
                            };
                        }
                        Thread thread2 = new Thread(start2);
                        thread2.Start();
                        thread2.Join();
                    }
                }
            }
            Options.HideDialog();
            return "OK";
        }

        public DataTable CreateNullDataTable()
        {
            SqlHelper helper = new SqlHelper();
            DataTable table = new DataTable();
            DataColumn column = new DataColumn("TimeKeeperTableListID");
            DataColumn column2 = new DataColumn("EmployeeCode");
            DataColumn column3 = new DataColumn("ShiftCode");
            DataColumn column4 = new DataColumn("Date");
            DataColumn column5 = new DataColumn("Symbol");
            DataColumn column6 = new DataColumn("TimeIn");
            DataColumn column7 = new DataColumn("TimeOut");
            DataColumn column8 = new DataColumn("Hour");
            DataColumn column9 = new DataColumn("DayHour");
            DataColumn column10 = new DataColumn("NightHour");
            DataColumn column11 = new DataColumn("PrivateHour");
            DataColumn column12 = new DataColumn("LateMinute");
            DataColumn column13 = new DataColumn("EarlyMinute");
            DataColumn column14 = new DataColumn("IsOverTime");
            DataColumn column15 = new DataColumn("IsWork");
            DataColumn column16 = new DataColumn("Sorted");
            DataColumn column17 = new DataColumn("Description");
            table.Columns.Add(column);
            table.Columns.Add(column2);
            table.Columns.Add(column3);
            table.Columns.Add(column4);
            table.Columns.Add(column5);
            table.Columns.Add(column6);
            table.Columns.Add(column7);
            table.Columns.Add(column8);
            table.Columns.Add(column9);
            table.Columns.Add(column10);
            table.Columns.Add(column11);
            table.Columns.Add(column12);
            table.Columns.Add(column13);
            table.Columns.Add(column14);
            table.Columns.Add(column15);
            table.Columns.Add(column16);
            table.Columns.Add(column17);
            table.Clear();
            return table;
        }

        public string Delete()
        {
            string[] myParams = new string[] { "@TimeKeeperTableListID", "@EmployeeCode", "@ShiftCode", "@Date", "@Symbol" };
            object[] myValues = new object[] { this.m_TimeKeeperTableListID, this.m_EmployeeCode, this.m_ShiftCode, this.m_Date, this.m_Symbol };
            SqlHelper helper = new SqlHelper();
            return helper.ExecuteNonQuery("HRM_TIMEKEEPER_Delete", myParams, myValues);
        }

        public string Delete(Guid TimeKeeperTableListID, string EmployeeCode, string ShiftCode, System.DateTime Date, string Symbol)
        {
            string[] myParams = new string[] { "@TimeKeeperTableListID", "@EmployeeCode", "@ShiftCode", "@Date", "@Symbol" };
            object[] myValues = new object[] { TimeKeeperTableListID, EmployeeCode, ShiftCode, Date, Symbol };
            SqlHelper helper = new SqlHelper();
            return helper.ExecuteNonQuery("HRM_TIMEKEEPER_Delete", myParams, myValues);
        }

        public string Delete(SqlConnection myConnection, Guid TimeKeeperTableListID, string EmployeeCode, string ShiftCode, System.DateTime Date, string Symbol)
        {
            string[] myParams = new string[] { "@TimeKeeperTableListID", "@EmployeeCode", "@ShiftCode", "@Date", "@Symbol" };
            object[] myValues = new object[] { TimeKeeperTableListID, EmployeeCode, ShiftCode, Date, Symbol };
            SqlHelper helper = new SqlHelper();
            return helper.ExecuteNonQuery(myConnection, "HRM_TIMEKEEPER_Delete", myParams, myValues);
        }

        public string Delete(SqlTransaction myTransaction, Guid TimeKeeperTableListID, string EmployeeCode, string ShiftCode, System.DateTime Date, string Symbol)
        {
            string[] myParams = new string[] { "@TimeKeeperTableListID", "@EmployeeCode", "@ShiftCode", "@Date", "@Symbol" };
            object[] myValues = new object[] { TimeKeeperTableListID, EmployeeCode, ShiftCode, Date, Symbol };
            SqlHelper helper = new SqlHelper();
            return helper.ExecuteNonQuery(myTransaction, "HRM_TIMEKEEPER_Delete", myParams, myValues);
        }

        public string DeleteByEmployeeDate(Guid TimeKeeperTableListID, string EmployeeCode, System.DateTime Date)
        {
            string[] myParams = new string[] { "@TimeKeeperTableListID", "@EmployeeCode", "@Date" };
            object[] myValues = new object[] { TimeKeeperTableListID, EmployeeCode, Date };
            SqlHelper helper = new SqlHelper {
                CommandType = CommandType.Text
            };
            return helper.ExecuteNonQuery("Delete From [HRM_TIMEKEEPER]\r\nWhere \r\n   [TimeKeeperTableListID] = @TimeKeeperTableListID\r\nAND \r\n   [EmployeeCode] = @EmployeeCode\r\nAND\r\n   [Date]=@Date\r\nAND [ShiftCode]<>''", myParams, myValues);
        }

        public string DeleteByEmployeeShift(Guid TimeKeeperTableListID, string EmployeeCode, string ShiftCode, System.DateTime Date)
        {
            string[] myParams = new string[] { "@TimeKeeperTableListID", "@EmployeeCode", "@ShiftCode", "@Date" };
            object[] myValues = new object[] { TimeKeeperTableListID, EmployeeCode, ShiftCode, Date };
            SqlHelper helper = new SqlHelper();
            return helper.ExecuteNonQuery("HRM_TIMEKEEPER_DeleteByEmployeeShift", myParams, myValues);
        }

        public bool Exist(Guid TimeKeeperTableListID, string EmployeeCode, string ShiftCode, System.DateTime Date, string Symbol)
        {
            bool hasRows = false;
            string[] myParams = new string[] { "@TimeKeeperTableListID", "@EmployeeCode", "@ShiftCode", "@Date", "@Symbol" };
            object[] myValues = new object[] { TimeKeeperTableListID, EmployeeCode, ShiftCode, Date, Symbol };
            SqlHelper helper = new SqlHelper();
            SqlDataReader reader = helper.ExecuteReader("HRM_TIMEKEEPER_Get", myParams, myValues);
            if (reader != null)
            {
                hasRows = reader.HasRows;
                reader.Close();
                helper.Close();
                reader = null;
            }
            return hasRows;
        }

        public string Get(Guid TimeKeeperTableListID, string EmployeeCode, string ShiftCode, System.DateTime Date, string Symbol)
        {
            string str = "";
            string[] myParams = new string[] { "@TimeKeeperTableListID", "@EmployeeCode", "@ShiftCode", "@Date", "@Symbol" };
            object[] myValues = new object[] { TimeKeeperTableListID, EmployeeCode, ShiftCode, Date, Symbol };
            SqlHelper helper = new SqlHelper();
            SqlDataReader reader = helper.ExecuteReader("HRM_TIMEKEEPER_Get", myParams, myValues);
            if (reader != null)
            {
                while (reader.Read())
                {
                    this.m_TimeKeeperTableListID = reader.GetGuid(reader.GetOrdinal("TimeKeeperTableListID"));
                    this.m_EmployeeCode = Convert.ToString(reader["EmployeeCode"]);
                    this.m_ShiftCode = Convert.ToString(reader["ShiftCode"]);
                    this.m_Date = Convert.ToDateTime(reader["Date"]);
                    this.m_Symbol = Convert.ToString(reader["Symbol"]);
                    this.m_TimeIn = Convert.ToDateTime(reader["TimeIn"]);
                    this.m_TimeOut = Convert.ToDateTime(reader["TimeOut"]);
                    this.m_Hour = Convert.ToDouble(reader["Hour"]);
                    this.m_DayHour = Convert.ToDouble(reader["DayHour"]);
                    this.m_NightHour = Convert.ToDouble(reader["NightHour"]);
                    this.m_PrivateHour = Convert.ToDouble(reader["PrivateHour"]);
                    this.m_LateMinute = Convert.ToInt32(reader["LateMinute"]);
                    this.m_EarlyMinute = Convert.ToInt32(reader["EarlyMinute"]);
                    this.m_IsOverTime = Convert.ToBoolean(reader["IsOverTime"]);
                    this.m_IsWork = Convert.ToBoolean(reader["IsWork"]);
                    this.m_Sorted = Convert.ToInt32(reader["Sorted"]);
                    this.m_Description = Convert.ToString(reader["Description"]);
                    str = "OK";
                }
                reader.Close();
                helper.Close();
                reader = null;
            }
            return str;
        }

        public string Get(SqlConnection myConnection, Guid TimeKeeperTableListID, string EmployeeCode, string ShiftCode, System.DateTime Date, string Symbol)
        {
            string str = "";
            string[] myParams = new string[] { "@TimeKeeperTableListID", "@EmployeeCode", "@ShiftCode", "@Date", "@Symbol" };
            object[] myValues = new object[] { TimeKeeperTableListID, EmployeeCode, ShiftCode, Date, Symbol };
            SqlHelper helper = new SqlHelper();
            SqlDataReader reader = helper.ExecuteReader(myConnection, "HRM_TIMEKEEPER_Get", myParams, myValues);
            if (reader != null)
            {
                while (reader.Read())
                {
                    this.m_TimeKeeperTableListID = reader.GetGuid(reader.GetOrdinal("TimeKeeperTableListID"));
                    this.m_EmployeeCode = Convert.ToString(reader["EmployeeCode"]);
                    this.m_ShiftCode = Convert.ToString(reader["ShiftCode"]);
                    this.m_Date = Convert.ToDateTime(reader["Date"]);
                    this.m_Symbol = Convert.ToString(reader["Symbol"]);
                    this.m_TimeIn = Convert.ToDateTime(reader["TimeIn"]);
                    this.m_TimeOut = Convert.ToDateTime(reader["TimeOut"]);
                    this.m_Hour = Convert.ToDouble(reader["Hour"]);
                    this.m_DayHour = Convert.ToDouble(reader["DayHour"]);
                    this.m_NightHour = Convert.ToDouble(reader["NightHour"]);
                    this.m_PrivateHour = Convert.ToDouble(reader["PrivateHour"]);
                    this.m_LateMinute = Convert.ToInt32(reader["LateMinute"]);
                    this.m_EarlyMinute = Convert.ToInt32(reader["EarlyMinute"]);
                    this.m_IsOverTime = Convert.ToBoolean(reader["IsOverTime"]);
                    this.m_IsWork = Convert.ToBoolean(reader["IsWork"]);
                    this.m_Sorted = Convert.ToInt32(reader["Sorted"]);
                    this.m_Description = Convert.ToString(reader["Description"]);
                    str = "OK";
                }
                reader.Close();
                helper.Close();
                reader = null;
            }
            return str;
        }

        public string Get(SqlTransaction myTransaction, Guid TimeKeeperTableListID, string EmployeeCode, string ShiftCode, System.DateTime Date, string Symbol)
        {
            string str = "";
            string[] myParams = new string[] { "@TimeKeeperTableListID", "@EmployeeCode", "@ShiftCode", "@Date", "@Symbol" };
            object[] myValues = new object[] { TimeKeeperTableListID, EmployeeCode, ShiftCode, Date, Symbol };
            SqlHelper helper = new SqlHelper();
            SqlDataReader reader = helper.ExecuteReader(myTransaction, "HRM_TIMEKEEPER_Get", myParams, myValues);
            if (reader != null)
            {
                while (reader.Read())
                {
                    this.m_TimeKeeperTableListID = reader.GetGuid(reader.GetOrdinal("TimeKeeperTableListID"));
                    this.m_EmployeeCode = Convert.ToString(reader["EmployeeCode"]);
                    this.m_ShiftCode = Convert.ToString(reader["ShiftCode"]);
                    this.m_Date = Convert.ToDateTime(reader["Date"]);
                    this.m_Symbol = Convert.ToString(reader["Symbol"]);
                    this.m_TimeIn = Convert.ToDateTime(reader["TimeIn"]);
                    this.m_TimeOut = Convert.ToDateTime(reader["TimeOut"]);
                    this.m_Hour = Convert.ToDouble(reader["Hour"]);
                    this.m_DayHour = Convert.ToDouble(reader["DayHour"]);
                    this.m_NightHour = Convert.ToDouble(reader["NightHour"]);
                    this.m_PrivateHour = Convert.ToDouble(reader["PrivateHour"]);
                    this.m_LateMinute = Convert.ToInt32(reader["LateMinute"]);
                    this.m_EarlyMinute = Convert.ToInt32(reader["EarlyMinute"]);
                    this.m_IsOverTime = Convert.ToBoolean(reader["IsOverTime"]);
                    this.m_IsWork = Convert.ToBoolean(reader["IsWork"]);
                    this.m_Sorted = Convert.ToInt32(reader["Sorted"]);
                    this.m_Description = Convert.ToString(reader["Description"]);
                    str = "OK";
                }
                reader.Close();
                helper.Close();
                reader = null;
            }
            return str;
        }

        public void Get(Guid TimeKeeperTableListID, string EmployeeCode, string ShiftCode, string Symbol, System.DateTime Date, System.DateTime TimeIn, System.DateTime TimeOut)
        {
            int lateMinute = 0;
            int earlyMinute = 0;
            DIC_SHIFT dic_shift = new DIC_SHIFT();
            dic_shift.Get(ShiftCode);
            System.DateTime time = new System.DateTime(Date.Year, Date.Month, Date.Day, dic_shift.BeginTime.Hour, dic_shift.BeginTime.Minute, dic_shift.BeginTime.Second);
            System.DateTime dateValue = new System.DateTime(Date.Year, Date.Month, Date.Day, dic_shift.EndTime.Hour, dic_shift.EndTime.Minute, dic_shift.EndTime.Second);
            if (dic_shift.IsOvernight)
            {
                dateValue = DateAndTime.DateAdd(DateInterval.Day, 1.0, dateValue);
            }
            if (Symbol == "+")
            {
                if ((TimeOut < dateValue) && (ShiftCode != ""))
                {
                    earlyMinute = MyDateTime.NumberMinute(TimeOut, dateValue);
                }
                else
                {
                    this.m_EarlyMinute = 0;
                }
                if ((TimeIn > time) && (ShiftCode != ""))
                {
                    lateMinute = MyDateTime.NumberMinute(time, TimeIn);
                }
                else
                {
                    lateMinute = 0;
                }
            }
            this.Get(TimeKeeperTableListID, EmployeeCode, ShiftCode, Symbol, Date, TimeIn, TimeOut, time, dateValue, lateMinute, earlyMinute);
        }

        public void Get(Guid TimeKeeperTableListID, string EmployeeCode, string ShiftCode, string Symbol, System.DateTime Date, int LateMinute, int EarlyMinute)
        {
            System.DateTime now = System.DateTime.Now;
            System.DateTime timeOut = System.DateTime.Now;
            DIC_SHIFT dic_shift = new DIC_SHIFT();
            dic_shift.Get(ShiftCode);
            System.DateTime date = new System.DateTime(Date.Year, Date.Month, Date.Day, dic_shift.BeginTime.Hour, dic_shift.BeginTime.Minute, dic_shift.BeginTime.Second);
            System.DateTime dateValue = new System.DateTime(Date.Year, Date.Month, Date.Day, dic_shift.EndTime.Hour, dic_shift.EndTime.Minute, dic_shift.EndTime.Second);
            if (dic_shift.IsOvernight)
            {
                dateValue = DateAndTime.DateAdd(DateInterval.Day, 1.0, dateValue);
            }
            if (Symbol == "+")
            {
                now = MyDateTime.AddMinute(date, LateMinute);
                timeOut = MyDateTime.MinusMinute(dateValue, EarlyMinute);
            }
            else
            {
                now = date;
                timeOut = dateValue;
            }
            this.Get(TimeKeeperTableListID, EmployeeCode, ShiftCode, Symbol, Date, now, timeOut, date, dateValue, LateMinute, EarlyMinute);
        }

        public void Get(Guid TimeKeeperTableListID, string EmployeeCode, string ShiftCode, string Symbol, System.DateTime Date, System.DateTime TimeIn, System.DateTime TimeOut, int Sorted, int Length)
        {
            int lateMinute = 0;
            int earlyMinute = 0;
            DIC_SHIFT dic_shift = new DIC_SHIFT();
            dic_shift.Get(ShiftCode);
            System.DateTime dateValue = Date;
            System.DateTime time2 = Date;
            if ((Length == 2) && dic_shift.IsBreak)
            {
                if (Sorted == 0)
                {
                    dateValue = new System.DateTime(Date.Year, Date.Month, Date.Day, dic_shift.BeginTime.Hour, dic_shift.BeginTime.Minute, dic_shift.BeginTime.Second);
                    time2 = new System.DateTime(Date.Year, Date.Month, Date.Day, dic_shift.BreakBeginTime.Hour, dic_shift.BreakBeginTime.Minute, dic_shift.BreakBeginTime.Second);
                }
                else
                {
                    dateValue = new System.DateTime(Date.Year, Date.Month, Date.Day, dic_shift.BreakEndTime.Hour, dic_shift.BreakEndTime.Minute, dic_shift.BreakEndTime.Second);
                    time2 = new System.DateTime(Date.Year, Date.Month, Date.Day, dic_shift.EndTime.Hour, dic_shift.EndTime.Minute, dic_shift.EndTime.Second);
                    if (dic_shift.IsBreakOvernight)
                    {
                        dateValue = DateAndTime.DateAdd(DateInterval.Day, 1.0, dateValue);
                        time2 = DateAndTime.DateAdd(DateInterval.Day, 1.0, time2);
                    }
                }
            }
            else
            {
                dateValue = new System.DateTime(Date.Year, Date.Month, Date.Day, dic_shift.BeginTime.Hour, dic_shift.BeginTime.Minute, dic_shift.BeginTime.Second);
                time2 = new System.DateTime(Date.Year, Date.Month, Date.Day, dic_shift.EndTime.Hour, dic_shift.EndTime.Minute, dic_shift.EndTime.Second);
                if (dic_shift.IsOvernight)
                {
                    time2 = DateAndTime.DateAdd(DateInterval.Day, 1.0, time2);
                }
            }
            if (Symbol == "+")
            {
                if ((TimeOut < time2) && (ShiftCode != ""))
                {
                    earlyMinute = MyDateTime.NumberMinute(time2, TimeOut);
                }
                else
                {
                    this.m_EarlyMinute = 0;
                }
                if ((TimeIn > dateValue) && (ShiftCode != ""))
                {
                    lateMinute = MyDateTime.NumberMinute(dateValue, TimeIn);
                }
                else
                {
                    lateMinute = 0;
                }
            }
            this.Get(TimeKeeperTableListID, EmployeeCode, ShiftCode, Symbol, Date, TimeIn, TimeOut, dateValue, time2, lateMinute, earlyMinute);
        }

        public void Get(Guid TimeKeeperTableListID, string EmployeeCode, string ShiftCode, string Symbol, System.DateTime Date, System.DateTime TimeIn, System.DateTime TimeOut, System.DateTime TimeInShift, System.DateTime TimeOutShift, int LateMinute, int EarlyMinute)
        {
            double num = 0.0;
            double num2 = 0.0;
            double num3 = 0.0;
            double num4 = 0.0;
            double num5 = 0.0;
            if (TimeOut > TimeIn)
            {
                if (((TimeIn >= TimeInShift) && (TimeOut <= TimeOutShift)) && (ShiftCode != ""))
                {
                    num = MyDateTime.NumberHour(TimeIn, TimeOut);
                }
                else if (((TimeIn < TimeInShift) && (TimeOut > TimeOutShift)) && (ShiftCode != ""))
                {
                    num = MyDateTime.NumberHour(TimeInShift, TimeOutShift);
                }
                else if (((TimeIn < TimeInShift) && (TimeOut <= TimeOutShift)) && (ShiftCode != ""))
                {
                    num = MyDateTime.NumberHour(TimeInShift, TimeOut);
                }
                else if (((TimeIn >= TimeInShift) && (TimeOut > TimeOutShift)) && (ShiftCode != ""))
                {
                    num = MyDateTime.NumberHour(TimeIn, TimeOutShift);
                }
                else
                {
                    num = MyDateTime.NumberHour(TimeIn, TimeOut);
                }
                double num6 = new HRM_TIMEKEEPER_BREAK().TotalBreakHour(TimeKeeperTableListID, EmployeeCode, ShiftCode, Date);
                num -= num6;
                DIC_TIMEKEEPER_FORMULA dic_timekeeper_formula = new DIC_TIMEKEEPER_FORMULA();
                dic_timekeeper_formula.Get();
                System.DateTime time = new System.DateTime(TimeIn.Year, TimeIn.Month, TimeIn.Day, 0, 0, 0);
                System.DateTime time2 = new System.DateTime(TimeIn.Year, TimeIn.Month, TimeIn.Day, dic_timekeeper_formula.EndTimeNight.Hour, dic_timekeeper_formula.EndTimeNight.Minute, dic_timekeeper_formula.EndTimeNight.Second);
                System.DateTime time3 = new System.DateTime(TimeIn.Year, TimeIn.Month, TimeIn.Day, dic_timekeeper_formula.BeginTimeNight.Hour, dic_timekeeper_formula.BeginTimeNight.Minute, dic_timekeeper_formula.BeginTimeNight.Second);
                System.DateTime time4 = DateAndTime.DateAdd(DateInterval.Day, 1.0, TimeIn);
                System.DateTime time5 = new System.DateTime(time4.Year, time4.Month, time4.Day, dic_timekeeper_formula.EndTimeNight.Hour, dic_timekeeper_formula.EndTimeNight.Minute, dic_timekeeper_formula.EndTimeNight.Second);
                if (TimeIn >= time2)
                {
                    num4 = 0.0;
                }
                else if (((TimeIn >= time) && (TimeOut <= time2)) && (TimeOut >= time))
                {
                    num4 = MyDateTime.NumberHour(TimeIn, TimeOut);
                }
                else if ((TimeIn >= time) && (TimeOut > time2))
                {
                    num4 = MyDateTime.NumberHour(TimeIn, time2);
                }
                else if ((TimeIn < time) && (TimeOut > time2))
                {
                    num4 = MyDateTime.NumberHour(time, time2);
                }
                else if (((TimeIn < time) && (TimeOut <= time2)) && (TimeOut >= time))
                {
                    num4 = MyDateTime.NumberHour(time, TimeOut);
                }
                else
                {
                    num4 = 0.0;
                }
                if (TimeOut <= time3)
                {
                    num5 = 0.0;
                }
                else if (((TimeIn >= time3) && (TimeOut <= time5)) && (TimeOut >= time3))
                {
                    num5 = MyDateTime.NumberHour(TimeIn, TimeOut);
                }
                else if ((TimeIn >= time3) && (TimeOut > time5))
                {
                    num5 = MyDateTime.NumberHour(TimeIn, time5);
                }
                else if ((TimeIn < time3) && (TimeOut > time5))
                {
                    num5 = MyDateTime.NumberHour(time3, time5);
                }
                else if (((TimeIn < time3) && (TimeOut <= time5)) && (TimeOut >= time3))
                {
                    num5 = MyDateTime.NumberHour(time3, TimeOut);
                }
                else
                {
                    num5 = 0.0;
                }
                num3 = num4 + num5;
                if ((num3 - num6) > 0.0)
                {
                    num3 -= num6;
                }
                num2 = num - num3;
                if ((Symbol != "+") && (ShiftCode != ""))
                {
                    TimeIn = TimeInShift;
                    TimeOut = TimeOutShift;
                    num = 0.0;
                    num2 = 0.0;
                    num3 = 0.0;
                    LateMinute = 0;
                    EarlyMinute = 0;
                }
                if (num < 0.0)
                {
                    num = 0.0;
                }
                if (num2 < 0.0)
                {
                    num2 = 0.0;
                }
                if (num3 < 0.0)
                {
                    num3 = 0.0;
                }
            }
            this.m_ShiftCode = ShiftCode;
            this.m_Symbol = Symbol;
            this.m_Date = Date;
            this.m_TimeIn = TimeIn;
            this.m_TimeOut = TimeOut;
            this.m_Hour = num;
            this.m_DayHour = num2;
            this.m_NightHour = num3;
            this.m_LateMinute = LateMinute;
            this.m_EarlyMinute = EarlyMinute;
        }

        public string GetByShift(Guid TimeKeeperTableListID, string EmployeeCode, string ShiftCode, System.DateTime Date)
        {
            string str = "";
            string[] myParams = new string[] { "@TimeKeeperTableListID", "@EmployeeCode", "@ShiftCode", "@Date" };
            object[] myValues = new object[] { TimeKeeperTableListID, EmployeeCode, ShiftCode, Date };
            SqlHelper helper = new SqlHelper();
            SqlDataReader reader = helper.ExecuteReader("HRM_TIMEKEEPER_GetByShift", myParams, myValues);
            if (reader != null)
            {
                while (reader.Read())
                {
                    this.m_TimeKeeperTableListID = reader.GetGuid(reader.GetOrdinal("TimeKeeperTableListID"));
                    this.m_EmployeeCode = Convert.ToString(reader["EmployeeCode"]);
                    this.m_ShiftCode = Convert.ToString(reader["ShiftCode"]);
                    this.m_Date = Convert.ToDateTime(reader["Date"]);
                    this.m_Symbol = Convert.ToString(reader["Symbol"]);
                    this.m_TimeIn = Convert.ToDateTime(reader["TimeIn"]);
                    this.m_TimeOut = Convert.ToDateTime(reader["TimeOut"]);
                    this.m_Hour = Convert.ToDouble(reader["Hour"]);
                    this.m_DayHour = Convert.ToDouble(reader["DayHour"]);
                    this.m_NightHour = Convert.ToDouble(reader["NightHour"]);
                    this.m_PrivateHour = Convert.ToDouble(reader["PrivateHour"]);
                    this.m_LateMinute = Convert.ToInt32(reader["LateMinute"]);
                    this.m_EarlyMinute = Convert.ToInt32(reader["EarlyMinute"]);
                    this.m_IsOverTime = Convert.ToBoolean(reader["IsOverTime"]);
                    this.m_IsWork = Convert.ToBoolean(reader["IsWork"]);
                    this.m_Sorted = Convert.ToInt32(reader["Sorted"]);
                    this.m_Description = Convert.ToString(reader["Description"]);
                    str = "OK";
                }
                reader.Close();
                helper.Close();
                reader = null;
            }
            return str;
        }

        public DataTable GetList()
        {
            SqlHelper helper = new SqlHelper();
            return helper.ExecuteDataTable("HRM_TIMEKEEPER_GetList");
        }

        public DataTable GetListByDate(string EmployeeCode, System.DateTime Date)
        {
            string[] myParams = new string[] { "@EmployeeCode", "@Date" };
            object[] myValues = new object[] { EmployeeCode, Date };
            SqlHelper helper = new SqlHelper();
            return helper.ExecuteDataTable("HRM_TIMEKEEPER_GetListByDate", myParams, myValues);
        }

        public DataTable GetListByDate1(string EmployeeCode, System.DateTime Date)
        {
            string[] myParams = new string[] { "@EmployeeCode", "@Date" };
            object[] myValues = new object[] { EmployeeCode, Date };
            SqlHelper helper = new SqlHelper {
                CommandType = CommandType.Text
            };
            return helper.ExecuteDataTable("Select ht.*,ds.ShiftName From [HRM_TIMEKEEPER] ht inner join DIC_SHIFT ds\r\n\ton ht.ShiftCode=ds.ShiftCode\r\n\twhere EmployeeCode=@EmployeeCode and day([Date])=day(@Date)\r\n\t\t\t\t\t\t\t\t\tand month([Date])=month(@Date)\r\n\t\t\t\t\t\t\t\t\tand year([Date])=year(@Date)\r\n\t\t\t\t\t\t\tand ds.ShiftCode<>'' and ht.Symbol<>'' and ht.Symbol<>'CN' and ht.Symbol<>'T7' and ht.Symbol<>'L'\r\n--\t\t\t\t\t\t\tand IsWork=1", myParams, myValues);
        }

        public DataTable GetListByDate2(string EmployeeCode, System.DateTime Date)
        {
            string[] myParams = new string[] { "@EmployeeCode", "@Date" };
            object[] myValues = new object[] { EmployeeCode, Date };
            SqlHelper helper = new SqlHelper {
                CommandType = CommandType.Text
            };
            return helper.ExecuteDataTable("Select ht.*,ds.ShiftName From [HRM_TIMEKEEPER] ht inner join DIC_SHIFT ds\r\n\ton ht.ShiftCode=ds.ShiftCode\r\n\twhere EmployeeCode=@EmployeeCode and day([Date])=day(@Date)\r\n\t\t\t\t\t\t\t\t\tand month([Date])=month(@Date)\r\n\t\t\t\t\t\t\t\t\tand year([Date])=year(@Date)\r\n\t\t\t\t\t\t\tand ds.ShiftCode<>''", myParams, myValues);
        }

        public DataTable GetListByEmployee(string EmployeeCode, int Month, int Year)
        {
            string[] myParams = new string[] { "@EmployeeCode", "@Month", "@Year" };
            object[] myValues = new object[] { EmployeeCode, Month, Year };
            SqlHelper helper = new SqlHelper();
            return helper.ExecuteDataTable("HRM_TIMEKEEPER_GetListByEmployee", myParams, myValues);
        }

        public DataTable GetListByShift(Guid TimeKeeperTableListID, string EmployeeCode, string ShiftCode, System.DateTime Date)
        {
            string[] myParams = new string[] { "@TimeKeeperTableListID", "@EmployeeCode", "@ShiftCode", "@Date" };
            object[] myValues = new object[] { TimeKeeperTableListID, EmployeeCode, ShiftCode, Date };
            SqlHelper helper = new SqlHelper();
            return helper.ExecuteDataTable("HRM_TIMEKEEPER_GetByShift", myParams, myValues);
        }

        public DataTable GetListBySymbol(int Level, string Code, int Year, string Symbol)
        {
            string[] myParams = new string[] { "@Level", "@Code", "@Year", "@Symbol" };
            object[] myValues = new object[] { Level, Code, Year, Symbol };
            SqlHelper helper = new SqlHelper();
            return helper.ExecuteDataTable("HRM_TIMEKEEPER_GetListBySymbol", myParams, myValues);
        }

        public DataTable GetListDate(string EmployeeCode, int Month, int Year)
        {
            string[] myParams = new string[] { "@EmployeeCode", "@Month", "@Year" };
            object[] myValues = new object[] { EmployeeCode, Month, Year };
            SqlHelper helper = new SqlHelper();
            return helper.ExecuteDataTable("HRM_TIMEKEEPER_GetListDate", myParams, myValues);
        }

        public DataTable GetListTotalYear(int Level, string Code, int Year, int Filter)
        {
            string[] myParams = new string[] { "@Level", "@Code", "@Year", "@Filter" };
            object[] myValues = new object[] { Level, Code, Year, Filter };
            SqlHelper helper = new SqlHelper();
            return helper.ExecuteDataTable("HRM_TIMEKEEPER_GetListTotalYear", myParams, myValues);
        }

        public string Insert()
        {
            string[] myParams = new string[] { 
                "@TimeKeeperTableListID", "@EmployeeCode", "@ShiftCode", "@Date", "@Symbol", "@TimeIn", "@TimeOut", "@Hour", "@DayHour", "@NightHour", "@PrivateHour", "@LateMinute", "@EarlyMinute", "@IsOverTime", "@IsWork", "@Sorted", 
                "@Description"
             };
            object[] myValues = new object[] { 
                this.m_TimeKeeperTableListID, this.m_EmployeeCode, this.m_ShiftCode, this.m_Date, this.m_Symbol, this.m_TimeIn, this.m_TimeOut, this.m_Hour, this.m_DayHour, this.m_NightHour, this.m_PrivateHour, this.m_LateMinute, this.m_EarlyMinute, this.m_IsOverTime, this.m_IsWork, this.m_Sorted, 
                this.m_Description
             };
            SqlHelper helper = new SqlHelper();
            return helper.ExecuteNonQuery("HRM_TIMEKEEPER_Insert", myParams, myValues);
        }

        public string Insert(SqlTransaction myTransaction)
        {
            string[] myParams = new string[] { 
                "@TimeKeeperTableListID", "@EmployeeCode", "@ShiftCode", "@Date", "@Symbol", "@TimeIn", "@TimeOut", "@Hour", "@DayHour", "@NightHour", "@PrivateHour", "@LateMinute", "@EarlyMinute", "@IsOverTime", "@IsWork", "@Sorted", 
                "@Description"
             };
            object[] myValues = new object[] { 
                this.m_TimeKeeperTableListID, this.m_EmployeeCode, this.m_ShiftCode, this.m_Date, this.m_Symbol, this.m_TimeIn, this.m_TimeOut, this.m_Hour, this.m_DayHour, this.m_NightHour, this.m_PrivateHour, this.m_LateMinute, this.m_EarlyMinute, this.m_IsOverTime, this.m_IsWork, this.m_Sorted, 
                this.m_Description
             };
            SqlHelper helper = new SqlHelper();
            return helper.ExecuteNonQuery(myTransaction, "HRM_TIMEKEEPER_Insert", myParams, myValues);
        }

        public string Insert(Guid TimeKeeperTableListID, string EmployeeCode, string ShiftCode, System.DateTime Date, string Symbol, System.DateTime TimeIn, System.DateTime TimeOut, double Hour, double DayHour, double NightHour, double PrivateHour, int LateMinute, int EarlyMinute, bool IsOverTime, bool IsWork, int Sorted, string Description)
        {
            string[] myParams = new string[] { 
                "@TimeKeeperTableListID", "@EmployeeCode", "@ShiftCode", "@Date", "@Symbol", "@TimeIn", "@TimeOut", "@Hour", "@DayHour", "@NightHour", "@PrivateHour", "@LateMinute", "@EarlyMinute", "@IsOverTime", "@IsWork", "@Sorted", 
                "@Description"
             };
            object[] myValues = new object[] { 
                TimeKeeperTableListID, EmployeeCode, ShiftCode, Date, Symbol, TimeIn, TimeOut, Hour, DayHour, NightHour, PrivateHour, LateMinute, EarlyMinute, IsOverTime, IsWork, Sorted, 
                Description
             };
            SqlHelper helper = new SqlHelper();
            return helper.ExecuteNonQuery("HRM_TIMEKEEPER_Insert", myParams, myValues);
        }

        public string Insert(SqlConnection myConnection, Guid TimeKeeperTableListID, string EmployeeCode, string ShiftCode, System.DateTime Date, string Symbol, System.DateTime TimeIn, System.DateTime TimeOut, double Hour, double DayHour, double NightHour, double PrivateHour, int LateMinute, int EarlyMinute, bool IsOverTime, bool IsWork, int Sorted, string Description)
        {
            string[] myParams = new string[] { 
                "@TimeKeeperTableListID", "@EmployeeCode", "@ShiftCode", "@Date", "@Symbol", "@TimeIn", "@TimeOut", "@Hour", "@DayHour", "@NightHour", "@PrivateHour", "@LateMinute", "@EarlyMinute", "@IsOverTime", "@IsWork", "@Sorted", 
                "@Description"
             };
            object[] myValues = new object[] { 
                TimeKeeperTableListID, EmployeeCode, ShiftCode, Date, Symbol, TimeIn, TimeOut, Hour, DayHour, NightHour, PrivateHour, LateMinute, EarlyMinute, IsOverTime, IsWork, Sorted, 
                Description
             };
            SqlHelper helper = new SqlHelper();
            return helper.ExecuteNonQuery(myConnection, "HRM_TIMEKEEPER_Insert", myParams, myValues);
        }

        public string Insert(SqlTransaction myTransaction, Guid TimeKeeperTableListID, string EmployeeCode, string ShiftCode, System.DateTime Date, string Symbol, System.DateTime TimeIn, System.DateTime TimeOut, double Hour, double DayHour, double NightHour, double PrivateHour, int LateMinute, int EarlyMinute, bool IsOverTime, bool IsWork, int Sorted, string Description)
        {
            string[] myParams = new string[] { 
                "@TimeKeeperTableListID", "@EmployeeCode", "@ShiftCode", "@Date", "@Symbol", "@TimeIn", "@TimeOut", "@Hour", "@DayHour", "@NightHour", "@PrivateHour", "@LateMinute", "@EarlyMinute", "@IsOverTime", "@IsWork", "@Sorted", 
                "@Description"
             };
            object[] myValues = new object[] { 
                TimeKeeperTableListID, EmployeeCode, ShiftCode, Date, Symbol, TimeIn, TimeOut, Hour, DayHour, NightHour, PrivateHour, LateMinute, EarlyMinute, IsOverTime, IsWork, Sorted, 
                Description
             };
            SqlHelper helper = new SqlHelper();
            return helper.ExecuteNonQuery(myTransaction, "HRM_TIMEKEEPER_Insert", myParams, myValues);
        }

        public string NewID()
        {
            return SqlHelper.GenCode("HRM_TIMEKEEPER", "TimeKeeperTableListID", "CV");
        }

        public static int ShiftAbsentDay(Guid TimeKeeperTableListID, string EmployeeCode, string ShiftCode)
        {
            int num = 0;
            string[] myParams = new string[] { "@TimeKeeperTableListID", "@EmployeeCode", "@ShiftCode" };
            object[] myValues = new object[] { TimeKeeperTableListID, EmployeeCode, ShiftCode };
            SqlHelper helper = new SqlHelper();
            SqlDataReader reader = helper.ExecuteReader("HRM_TIMEKEEPER_ShiftAbsentDay", myParams, myValues);
            if (reader != null)
            {
                while (reader.Read())
                {
                    num = Convert.ToInt32(reader["ShiftAbsentDay"]);
                }
                reader.Close();
                helper.Close();
                reader = null;
            }
            return num;
        }

        public static int ShiftEarlyMinute(Guid TimeKeeperTableListID, string EmployeeCode, string ShiftCode)
        {
            int num = 0;
            string[] myParams = new string[] { "@TimeKeeperTableListID", "@EmployeeCode", "@ShiftCode" };
            object[] myValues = new object[] { TimeKeeperTableListID, EmployeeCode, ShiftCode };
            SqlHelper helper = new SqlHelper();
            SqlDataReader reader = helper.ExecuteReader("HRM_TIMEKEEPER_ShiftEarlyMinute", myParams, myValues);
            if (reader != null)
            {
                while (reader.Read())
                {
                    num = Convert.ToInt32(reader["ShiftEarlyMinute"]);
                }
                reader.Close();
                helper.Close();
                reader = null;
            }
            return num;
        }

        public static int ShiftFurloughDay(Guid TimeKeeperTableListID, string EmployeeCode, string ShiftCode)
        {
            int num = 0;
            string[] myParams = new string[] { "@TimeKeeperTableListID", "@EmployeeCode", "@ShiftCode" };
            object[] myValues = new object[] { TimeKeeperTableListID, EmployeeCode, ShiftCode };
            SqlHelper helper = new SqlHelper();
            SqlDataReader reader = helper.ExecuteReader("HRM_TIMEKEEPER_ShiftFurloughDay", myParams, myValues);
            if (reader != null)
            {
                while (reader.Read())
                {
                    num = Convert.ToInt32(reader["ShiftFurloughDay"]);
                }
                reader.Close();
                helper.Close();
                reader = null;
            }
            return num;
        }

        public static int ShiftLateMinute(Guid TimeKeeperTableListID, string EmployeeCode, string ShiftCode)
        {
            int num = 0;
            string[] myParams = new string[] { "@TimeKeeperTableListID", "@EmployeeCode", "@ShiftCode" };
            object[] myValues = new object[] { TimeKeeperTableListID, EmployeeCode, ShiftCode };
            SqlHelper helper = new SqlHelper();
            SqlDataReader reader = helper.ExecuteReader("HRM_TIMEKEEPER_ShiftLateMinute", myParams, myValues);
            if (reader != null)
            {
                while (reader.Read())
                {
                    num = Convert.ToInt32(reader["ShiftLateMinute"]);
                }
                reader.Close();
                helper.Close();
                reader = null;
            }
            return num;
        }

        public static double ShiftTotalHour(Guid TimeKeeperTableListID, string EmployeeCode, string ShiftCode)
        {
            double num = 0.0;
            string[] myParams = new string[] { "@TimeKeeperTableListID", "@EmployeeCode", "@ShiftCode" };
            object[] myValues = new object[] { TimeKeeperTableListID, EmployeeCode, ShiftCode };
            SqlHelper helper = new SqlHelper();
            SqlDataReader reader = helper.ExecuteReader("HRM_TIMEKEEPER_ShiftTotalHour", myParams, myValues);
            if (reader != null)
            {
                while (reader.Read())
                {
                    num = Convert.ToDouble(reader["ShiftTotalHour"]);
                }
                reader.Close();
                helper.Close();
                reader = null;
            }
            return num;
        }

        public string Update()
        {
            string[] myParams = new string[] { 
                "@TimeKeeperTableListID", "@EmployeeCode", "@ShiftCode", "@Date", "@Symbol", "@TimeIn", "@TimeOut", "@Hour", "@DayHour", "@NightHour", "@PrivateHour", "@LateMinute", "@EarlyMinute", "@IsOverTime", "@IsWork", "@Sorted", 
                "@Description"
             };
            object[] myValues = new object[] { 
                this.m_TimeKeeperTableListID, this.m_EmployeeCode, this.m_ShiftCode, this.m_Date, this.m_Symbol, this.m_TimeIn, this.m_TimeOut, this.m_Hour, this.m_DayHour, this.m_NightHour, this.m_PrivateHour, this.m_LateMinute, this.m_EarlyMinute, this.m_IsOverTime, this.m_IsWork, this.m_Sorted, 
                this.m_Description
             };
            SqlHelper helper = new SqlHelper();
            return helper.ExecuteNonQuery("HRM_TIMEKEEPER_Update", myParams, myValues);
        }

        public string Update(Guid TimeKeeperTableListID, string EmployeeCode, string ShiftCode, System.DateTime Date, string Symbol, System.DateTime TimeIn, System.DateTime TimeOut, double Hour, double DayHour, double NightHour, double PrivateHour, int LateMinute, int EarlyMinute, bool IsOverTime, bool IsWork, int Sorted, string Description)
        {
            string[] myParams = new string[] { 
                "@TimeKeeperTableListID", "@EmployeeCode", "@ShiftCode", "@Date", "@Symbol", "@TimeIn", "@TimeOut", "@Hour", "@DayHour", "@NightHour", "@PrivateHour", "@LateMinute", "@EarlyMinute", "@IsOverTime", "@IsWork", "@Sorted", 
                "@Description"
             };
            object[] myValues = new object[] { 
                TimeKeeperTableListID, EmployeeCode, ShiftCode, Date, Symbol, TimeIn, TimeOut, Hour, DayHour, NightHour, PrivateHour, LateMinute, EarlyMinute, IsOverTime, IsWork, Sorted, 
                Description
             };
            SqlHelper helper = new SqlHelper();
            return helper.ExecuteNonQuery("HRM_TIMEKEEPER_Update", myParams, myValues);
        }

        public string Update(SqlConnection myConnection, Guid TimeKeeperTableListID, string EmployeeCode, string ShiftCode, System.DateTime Date, string Symbol, System.DateTime TimeIn, System.DateTime TimeOut, double Hour, double DayHour, double NightHour, double PrivateHour, int LateMinute, int EarlyMinute, bool IsOverTime, bool IsWork, int Sorted, string Description)
        {
            string[] myParams = new string[] { 
                "@TimeKeeperTableListID", "@EmployeeCode", "@ShiftCode", "@Date", "@Symbol", "@TimeIn", "@TimeOut", "@Hour", "@DayHour", "@NightHour", "@PrivateHour", "@LateMinute", "@EarlyMinute", "@IsOverTime", "@IsWork", "@Sorted", 
                "@Description"
             };
            object[] myValues = new object[] { 
                TimeKeeperTableListID, EmployeeCode, ShiftCode, Date, Symbol, TimeIn, TimeOut, Hour, DayHour, NightHour, PrivateHour, LateMinute, EarlyMinute, IsOverTime, IsWork, Sorted, 
                Description
             };
            SqlHelper helper = new SqlHelper();
            return helper.ExecuteNonQuery(myConnection, "HRM_TIMEKEEPER_Update", myParams, myValues);
        }

        public string Update(SqlTransaction myTransaction, Guid TimeKeeperTableListID, string EmployeeCode, string ShiftCode, System.DateTime Date, string Symbol, System.DateTime TimeIn, System.DateTime TimeOut, double Hour, double DayHour, double NightHour, double PrivateHour, int LateMinute, int EarlyMinute, bool IsOverTime, bool IsWork, int Sorted, string Description)
        {
            string[] myParams = new string[] { 
                "@TimeKeeperTableListID", "@EmployeeCode", "@ShiftCode", "@Date", "@Symbol", "@TimeIn", "@TimeOut", "@Hour", "@DayHour", "@NightHour", "@PrivateHour", "@LateMinute", "@EarlyMinute", "@IsOverTime", "@IsWork", "@Sorted", 
                "@Description"
             };
            object[] myValues = new object[] { 
                TimeKeeperTableListID, EmployeeCode, ShiftCode, Date, Symbol, TimeIn, TimeOut, Hour, DayHour, NightHour, PrivateHour, LateMinute, EarlyMinute, IsOverTime, IsWork, Sorted, 
                Description
             };
            SqlHelper helper = new SqlHelper();
            return helper.ExecuteNonQuery(myTransaction, "HRM_TIMEKEEPER_Update", myParams, myValues);
        }

        public string UpdateSymbol(Guid TimeKeeperTableListID, string EmployeeCode, string ShiftCode, System.DateTime Date, string Symbol, System.DateTime TimeIn, System.DateTime TimeOut, double Hour, double DayHour, double NightHour, double PrivateHour, int LateMinute, int EarlyMinute, bool IsOverTime, bool IsWork, int Sorted, string Description)
        {
            string[] myParams = new string[] { 
                "@TimeKeeperTableListID", "@EmployeeCode", "@ShiftCode", "@Date", "@Symbol", "@TimeIn", "@TimeOut", "@Hour", "@DayHour", "@NightHour", "@PrivateHour", "@LateMinute", "@EarlyMinute", "@IsOverTime", "@IsWork", "@Sorted", 
                "@Description"
             };
            object[] myValues = new object[] { 
                TimeKeeperTableListID, EmployeeCode, ShiftCode, Date, Symbol, TimeIn, TimeOut, Hour, DayHour, NightHour, PrivateHour, LateMinute, EarlyMinute, IsOverTime, IsWork, Sorted, 
                Description
             };
            SqlHelper helper = new SqlHelper();
            return helper.ExecuteNonQuery("HRM_TIMEKEEPER_UpdateSymbol", myParams, myValues);
        }

        [DisplayName("Date"), Category("Primary Key")]
        public System.DateTime Date
        {
            get
            {
                return this.m_Date;
            }
            set
            {
                this.m_Date = value;
            }
        }

        [DisplayName("DayHour"), Category("Column")]
        public double DayHour
        {
            get
            {
                return this.m_DayHour;
            }
            set
            {
                this.m_DayHour = value;
            }
        }

        [DisplayName("Description"), Category("Column")]
        public string Description
        {
            get
            {
                return this.m_Description;
            }
            set
            {
                this.m_Description = value;
            }
        }

        [Category("Column"), DisplayName("EarlyMinute")]
        public int EarlyMinute
        {
            get
            {
                return this.m_EarlyMinute;
            }
            set
            {
                this.m_EarlyMinute = value;
            }
        }

        [DisplayName("EmployeeCode"), Category("Primary Key")]
        public string EmployeeCode
        {
            get
            {
                return this.m_EmployeeCode;
            }
            set
            {
                this.m_EmployeeCode = value;
            }
        }

        [Category("Column"), DisplayName("Hour")]
        public double Hour
        {
            get
            {
                return this.m_Hour;
            }
            set
            {
                this.m_Hour = value;
            }
        }

        [DisplayName("IsOverTime"), Category("Column")]
        public bool IsOverTime
        {
            get
            {
                return this.m_IsOverTime;
            }
            set
            {
                this.m_IsOverTime = value;
            }
        }

        [Category("Column"), DisplayName("IsWork")]
        public bool IsWork
        {
            get
            {
                return this.m_IsWork;
            }
            set
            {
                this.m_IsWork = value;
            }
        }

        [Category("Column"), DisplayName("LateMinute")]
        public int LateMinute
        {
            get
            {
                return this.m_LateMinute;
            }
            set
            {
                this.m_LateMinute = value;
            }
        }

        [Category("Column"), DisplayName("NightHour")]
        public double NightHour
        {
            get
            {
                return this.m_NightHour;
            }
            set
            {
                this.m_NightHour = value;
            }
        }

        [DisplayName("PrivateHour"), Category("Column")]
        public double PrivateHour
        {
            get
            {
                return this.m_PrivateHour;
            }
            set
            {
                this.m_PrivateHour = value;
            }
        }

        public string ProductName
        {
            get
            {
                return "Class HRM_TIMEKEEPER";
            }
        }

        public string ProductVersion
        {
            get
            {
                return "1.0.0.0";
            }
        }

        [Category("Primary Key"), DisplayName("ShiftCode")]
        public string ShiftCode
        {
            get
            {
                return this.m_ShiftCode;
            }
            set
            {
                this.m_ShiftCode = value;
            }
        }

        [Category("Column"), DisplayName("Sorted")]
        public int Sorted
        {
            get
            {
                return this.m_Sorted;
            }
            set
            {
                this.m_Sorted = value;
            }
        }

        [Category("Primary Key"), DisplayName("Symbol")]
        public string Symbol
        {
            get
            {
                return this.m_Symbol;
            }
            set
            {
                this.m_Symbol = value;
            }
        }

        [DisplayName("TimeIn"), Category("Column")]
        public System.DateTime TimeIn
        {
            get
            {
                return this.m_TimeIn;
            }
            set
            {
                this.m_TimeIn = value;
            }
        }

        [Category("Primary Key"), DisplayName("TimeKeeperTableListID")]
        public Guid TimeKeeperTableListID
        {
            get
            {
                return this.m_TimeKeeperTableListID;
            }
            set
            {
                this.m_TimeKeeperTableListID = value;
            }
        }

        [DisplayName("TimeOut"), Category("Column")]
        public System.DateTime TimeOut
        {
            get
            {
                return this.m_TimeOut;
            }
            set
            {
                this.m_TimeOut = value;
            }
        }
    }
}

